home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 #2 / Ham Radio 2000 - Volume 2.iso / HAMV2 / TCP_IP / TNOS230S / RIP.H < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-31  |  7.1 KB  |  215 lines

  1. #ifndef _RIP_H
  2. #define _RIP_H
  3.   
  4. /* Routing Information Protocol (RIP)
  5.  *
  6.  *  This code is derived from the 4.2 BSD version which was
  7.  * used as a spec since no formal specification is known to exist.
  8.  * See RFC 1009, Gateway Requirements, for more details. AGB 4-29-88
  9.  *
  10.  * The draft RIP RFC was used to develop most of this code. The above
  11.  * referred to the basics of the rip_recv() function of RIP.C. The RIP
  12.  * RFC has now been issued as RFC1058. AGB 7-23-88
  13.  *
  14.  * Substantially rewritten and integrated into NOS 9/1989 by KA9Q
  15.  *
  16.  * Mods by PA0GRI
  17.  *
  18.  * Rehack for RIP-2 (RFC1388) by N0POY 4/1993
  19.  *
  20.  * Beta release 8/12/93 V0.9
  21.  *
  22.  * 2/19/94 release V1.0
  23.  *
  24.  *
  25.  */
  26.   
  27. #ifndef _MBUF_H
  28. #include "mbuf.h"
  29. #endif
  30.   
  31. #ifndef _IFACE_H
  32. #include "iface.h"
  33. #endif
  34.   
  35. #ifndef _UDP_H
  36. #include "udp.h"
  37. #endif
  38.   
  39. #define  RIP_VERSION_0           0
  40. #define  RIP_VERSION_1           1
  41. #define  RIP_VERSION_2           2
  42. #define  RIP_VERSION_X           3   /* Tied up with RIP98, always one above "official" RIP version */
  43. #define  RIP_VERSION_98          98
  44. #define  RIP_VERSIONS            4   /* +1 greater than official to cope with RIP98 */
  45.   
  46. #define  RIP_METRIC_UNREACHABLE  16
  47. #define  RIP_INFINITY            RIP_METRIC_UNREACHABLE
  48. #define  RIP_METRIC_SHUTDOWN     (RIP_METRIC_UNREACHABLE - 1)
  49.   
  50. #define  RIP_AUTH_SIZE           16
  51.   
  52. #define  RIP_PKTSIZE             512
  53. #define  RIP_HEADER              4
  54. #define  RIP_ENTRY               20
  55. #define  RIP98_ENTRY             6
  56. #define  RIP_ADDR_MC             0xe0000009  /* 224.0.0.9 */
  57. #define  RIP_PORT                520
  58. #define  RIP_HOP                 1        /* Minimum hop count when passing through */
  59.   
  60. #define  RIP_AF_UNSPEC           0        /* Unknown family */
  61. #define  RIP_AF_INET             2        /* IP Family */
  62. #define  RIP_AF_AUTH             0xffff   /* Authetication header */
  63. #define  RIP_NO_AUTH             "NONE"   /* No authentication */
  64.   
  65. #define  RIP_AUTH_NONE           0
  66. #define  RIP_AUTH_SIMPLE         2
  67. #define  RIP_TTL                 240      /* Default time-to-live for an entry */
  68. #define  RIP98_MAX_FRAME         30  
  69.  
  70. /*
  71.  * Packet types.
  72.  */
  73.   
  74. #define  RIPCMD_REQUEST          1        /* want info */
  75. #define  RIPCMD_RESPONSE         2        /* responding to request */
  76. #define  RIPCMD_TRACEON          3        /* turn tracing on */
  77. #define  RIPCMD_TRACEOFF         4        /* turn it off */
  78. #define  RIPCMD_POLL             5        /* like request, but anyone answers */
  79. #define  RIPCMD_POLLENTRY        6        /* like poll, but for entire entry */
  80. #define  RIPCMD_MAX              7
  81.   
  82.   
  83. /* RIP Flags */
  84.   
  85. #define  RIP_SPLIT               0x01     /* Do split horizon processing */
  86. #define  RIP_US                  0x02     /* Include ourselves in the list */
  87. #define  RIP_BROADCAST           0x04     /* Broadcast RIP packets */
  88. #define  RIP_MULTICAST           0x08     /* Multicast RIP packets */
  89. #define  RIP_POISON              0x10     /* Poisoned reverse on */
  90. #define  RIP_AUTHENTICATE        0x20     /* Authenticate each packet */
  91.   
  92.   
  93. /* RIP statistics counters */
  94. struct rip_stat {
  95.     struct version_data {
  96.         int32 output;        /* Packets sent */
  97.         int32 rcvd;          /* Packets received */
  98.         int32 request;       /* Number of request packets received */
  99.         int32 response;      /* Number of responses received */
  100.         int32 unknown;       /* Number of unknown command pkts received */
  101.     } vdata[RIP_VERSIONS];
  102.     int32 version;          /* Number of version errors */
  103.     int32 addr_family;      /* Number of address family errors */
  104.     int32 refusals;         /* Number of packets dropped from a host
  105.                               on the refuse list */
  106.     int32 wrong_domain;     /* Refused due to wrong domain for interface */
  107.     int32 auth_fail;        /* Authentication failures */
  108.     int32 unknown_auth;     /* Unknown authentication type */
  109. };
  110.   
  111. struct rip_list {
  112.     struct rip_list *prev;
  113.     struct rip_list *next;   /* doubly linked list */
  114.   
  115.    /* address to scream at periodically:
  116.     * this address must have a direct network interface route and an
  117.     * ARP entry for the appropriate  hardware broadcast address, if approp.
  118.     */
  119.     uint32 dest;
  120.   
  121.    /* basic rate of RIP clocks on this net interface */
  122.     int32 interval;
  123.   
  124.     struct timer rip_time;     /* time to output next on this net. iface */
  125.   
  126.     /* the interface to transmit on  and receive from */
  127.     struct iface *iface;
  128.     char  rip_version;         /* Type of RIP packets */
  129.     int16 flags;
  130.     int16 domain;              /* Routing domain in */
  131.     int16 route_tag;           /* Route tag to send */
  132.     uint32 proxy_route;        /* For Proxy RIP-2, 0 if none */
  133.     char rip_auth_code[RIP_AUTH_SIZE+1];
  134.                               /* Authentication code to send */
  135. };
  136. #define  NULLRL   (struct rip_list *)0
  137.   
  138. struct rip_refuse {
  139.     struct rip_refuse *prev;
  140.     struct rip_refuse *next;
  141.     uint32    target;
  142. };
  143. #define  NULLREF  (struct rip_refuse *)0
  144.   
  145. struct rip_auth {
  146.     struct rip_auth *prev;
  147.     struct rip_auth *next;
  148.     char *ifc_name;            /* Name of the interface */
  149.     int16 domain;              /* Check against valid routing domain */
  150.     char rip_auth_code[RIP_AUTH_SIZE+1];
  151.                               /* Authentication password accepted */
  152. };
  153. #define  NULLAUTH (struct rip_auth *)0
  154. #define  DEFAULTIFC     "DEFAULT"
  155.   
  156. /* Host format for the RIP-II header */
  157.   
  158. struct rip_head {
  159.     unsigned char rip_cmd;
  160.     unsigned char rip_vers;
  161.     unsigned short rip_domain;
  162. };
  163.   
  164. /* Host format of a single entry in a RIP response packet */
  165. struct rip_route {
  166.     int16 rip_family;
  167.     int16 rip_tag;
  168.     uint32 rip_dest;
  169.     uint32 rip_dest_mask;
  170.     uint32 rip_router;
  171.     int32 rip_metric;
  172. };
  173.   
  174. /* Host format of an authentication packet */
  175. struct rip_authenticate {
  176.     int16 rip_family;
  177.     int16 rip_auth_type;
  178.     char  rip_auth_str[RIP_AUTH_SIZE];
  179. };
  180.   
  181. /* RIP primitives */
  182.   
  183. int rip_init (void);
  184. void rt_timeout (void *s);
  185. int rip_add (uint32 dest,int32 interval,char flags, char version,
  186. char authpass[RIP_AUTH_SIZE], int16 domain, int16 route_tag, uint32 proxy);
  187. int riprefadd (uint32 gateway);
  188. int riprefdrop (uint32 gateway);
  189. int ripreq (uint32 dest,int16 replyport,int16 version);
  190. int rip_drop (uint32 dest,int16 domain);
  191. int ripauthdrop (char *ifcname,int16 domain);
  192. int ripauthadd (char const *ifcname,int16 domain,char const *password);
  193. void pullentry (struct rip_route *ep,struct mbuf **bpp);
  194. void pull98entry (struct rip_route *ep,struct mbuf **bpp);
  195. void rip_shout (void *p);
  196.   
  197. /* RIP Definition */
  198.   
  199. extern int16 Rip_trace;
  200. extern FILE *Rip_trace_file;
  201. extern char *Rip_trace_fname;
  202. extern int Rip_merge;
  203. extern int32 Rip_ttl;
  204. extern int16 Rip_ver_refuse;
  205. extern int Rip_default_refuse;
  206. extern int rip98allow;
  207. extern struct rip_stat Rip_stat;
  208. extern struct rip_list *Rip_list;
  209. extern struct rip_refuse *Rip_refuse;
  210. extern struct rip_auth *Rip_auth;
  211. extern struct udp_cb *Rip_cb;  
  212.  
  213. #endif  /* _RIP_H */
  214.   
  215.